<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title data-i18n="resources.text_mapOverlay"></title>
    <script type="text/javascript" src="../js/include-web.js"></script>
    <script type="text/javascript" src="../../dist/ol/include-ol.js"></script>
  </head>
  <body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
    <div id="map" style="width: 100%; height: 100%"></div>
    <script type="text/javascript">
      var map,
        urlWorld =
          (window.isLocal ? window.server : 'https://iserver.supermap.io') +
          '/iserver/services/map-world/rest/maps/World',
        urlJinjing =
          (window.isLocal ? window.server : 'https://iserver.supermap.io') +
          '/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图';
      // 方式一：1.调用 ol.supermap.initMap，根据 SuperMap iServer 地图服务的地图信息，创建地图和底图
      //         2.调用 ol.source.TileSuperMapRest 创建叠加图层
      ol.supermap
        .initMap(urlWorld, {
          mapOptions: {
            // ol v7版本用法为ol.control.defaults.defaults； v6版本以下用法为ol.control.defaults
            controls: ol.control.defaults.defaults({ attributionOptions: { collapsed: false } })
              .extend([new ol.supermap.control.Logo({ link: "https://iclient.supermap.io" })])
          },
          viewOptions: {
            center: [116.85, 39.79],
            zoom: 8
          }
        })
        .then(({ map, source }) => {
          var Jinjing = new ol.layer.Tile({
            source: new ol.source.TileSuperMapRest({
              url: urlJinjing,
              tileGrid: source.getTileGrid()
            })
          });
          map.addLayer(Jinjing);
        });
      /* 方式二：1.调用 ol.supermap.MapService，获取 SuperMap iServer 地图服务的地图信息
                2.调用 ol.supermap.viewOptionsFromMapJSON 获取地图视图参数
                3.调用 ol.Map 创建地图
                4.调用 ol.layer.Tile 与 ol.source.TileSuperMapRest 创建底图和叠加图层
         new ol.supermap.MapService(urlJinjing).getMapInfo(function (serviceResult) {
        const mapObj = serviceResult.result;
        map = new ol.Map({
          target: 'map',
          // ol v7版本用法为ol.control.defaults.defaults； v6版本以下用法为ol.control.defaults
          controls: ol.control.defaults.defaults({ attributionOptions: { collapsed: false } })
            .extend([new ol.supermap.control.Logo({ link: "https://iclient.supermap.io" })]),
          view: new ol.View(ol.supermap.viewOptionsFromMapJSON(mapObj))
        });
        var worldLayer = new ol.layer.Tile({
          source: new ol.source.TileSuperMapRest({
            url: urlWorld
          }),
          projection: 'EPSG:4326'
        });
        map.addLayer(worldLayer);
        var jinJingLayer = new ol.layer.Tile({
          source: new ol.source.TileSuperMapRest(ol.source.TileSuperMapRest.optionsFromMapJSON(urlJinjing, mapObj))
        });
        map.addLayer(jinJingLayer);
      });
      */
    </script>
  </body>
</html>
